<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="button" value="弹窗"> 
  <script>
    // 99%的用户是不登陆的 先不加在登录框， 性能更好 
  let offset = 20, index = 1;
  function Modal(pos) {
    this.offset = pos || 20
  }
  Modal.prototype.create = function() {
    const oDiv = document.createElement('div');
    oDiv.style.left = (++index) * this.offset + 'px';
    oDiv.style.top = (++index) * this.offset + 'px';
    oDiv.innerHTML = index
    return oDiv;
  }
  const oBtn = document.querySelector("input");
  oBtn.addEventListener('click', function() {
    // 动态加载 
    let modal = new Modal();
    document.body.appendChild(modal.create());
  }, false)
  </script>
</body>
</html>
